#include <vector>
class Solution
{
public:
    int MLS(vector<int>& arr)
    {
        if (arr.size() == 1)  return 1;

        sort(arr.begin(), arr.end());
        int ans = 1;
        int tmp = 1;

        for (int i = 1; i < arr.size(); i++)
        {
            if (arr[i] - arr[i - 1] == 1)
                tmp += 1;
            else if (arr[i] == arr[i - 1])
                continue;
            else
                tmp = 1;
            ans = max(ans, tmp);
        }

        return ans;
    }
};